package acwing._1_1AlgorithmBasic._5DynamicProgramming;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._1_1AlgorithmBasic._5DynamicProgramming
 * @File : Q0005.java
 * @Author : WangRuoyu
 * @Date : 2023/4/6 10:09
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q0005 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");
        int N = Integer.parseInt(words[0]);
        int V = Integer.parseInt(words[1]);

        // 二进制法优化多重背包问题，将多重背包转化成01背包
        int[] w = new int[N * 12 + 1];
        int[] v = new int[N * 12 + 1];
        int cnt = 0;
        for (int i = 1; i <= N; ++i) {
            words = br.readLine().split(" ");
            int a = Integer.parseInt(words[0]);
            int b = Integer.parseInt(words[1]);
            int s = Integer.parseInt(words[2]);
            int k = 1;
            while (k <= s) {
                cnt++;
                v[cnt] = k * a;
                w[cnt] = k * b;
                s -= k;
                k *= 2;
            }
            if (s > 0) {
                cnt++;
                v[cnt] = s * a;
                w[cnt] = s * b;
            }
        }

        int[] f = new int[V + 1];
        for (int i = 1; i <= cnt; ++i) {
            for (int j = V; j >= v[i]; --j) {
                f[j] = Math.max(f[j], f[j - v[i]] + w[i]);
            }
        }
        System.out.println(f[V]);
    }
}

